<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class FormItem extends Bones implements IRenderable {

	protected $ID;
	protected $name;

	protected $type;
	protected $displayFormat;
	protected $editorType;
	protected $value;
	protected $defaultValue;

	protected $left;
	protected $top;
	protected $height;
	protected $width;

	protected $title;
	protected $titleAlign;
	protected $showTitle;
	protected $titleColSpan;
	protected $titleOrientation;
	protected $titleStyle;
	protected $titleVAlign;
	protected $wrapTitle;

	protected $hint;
	protected $hintStyle;
	protected $showHint;

	protected $hoverAlign;
	protected $hoverDelay;
	protected $hoverWidth;
	protected $hoverHeight;
	protected $hoverOpacity;
	protected $hoverStyle;
	protected $hoverVAlign;
	protected $prompt;

	protected $iconWidth;
	protected $iconHeight;
	protected $iconVAlign;
	protected $iconPrompt;
	protected $icons;
	protected $defaultIconSrc;
	protected $showIcons;
	protected $showOverIcons;
	protected $showValueIconOnly;
	protected $suppressValueIcon;

	protected $valueIcons;
	protected $valueIconHeight;
	protected $valueIconWidth;
	protected $valueIconSize;
	protected $valueIconLeftPadding;
	protected $valueIconRightPadding;

	protected $imageURLPrefix;
	protected $imageURLSuffix;

	protected $emptyDisplayValue;
	protected $multipleValueSeparator;

	protected $align;
	protected $cellHeight;
	protected $cellStyle;
	protected $colSpan;
	protected $startRow;
	protected $endRow;
	protected $rowSpan;
	protected $textAlign;
	protected $textBoxStyle;

	protected $errorIconHeight;
	protected $errorIconSrc;
	protected $errorIconWidth;
	protected $errorMessageWidth;
	protected $errorOrientation;
	protected $showErrorIcon;
	protected $showErrorStyle;
	protected $showErrorText;

	protected $dateFormatter;
	protected $inputFormat;
	protected $timeFormatter;

	protected $alwaysFetchMissingValues;
	protected $fetchMissingValue;

	protected $filterLocally;

	protected $accessKey;
	protected $globalTabIndex;
	protected $tabIndex;

	protected $canFocus;
	protected $selectOnFocus;
	protected $showFocused;
	protected $showFocusedIcons;

	protected $disabled;
	protected $showDisabled;
	protected $visible;

	protected $optionDataSource;
	protected $optionCriteria;
	protected $displayField;
	protected $valueField;

	protected $valueMap;

	protected $rejectInvalidValueOnChange;
	protected $required;
	protected $requiredMessage;
	protected $stopOnError;
	
	protected $synchronousValidation;
	protected $validateOnChange;
	protected $validateOnExit;
	protected $validators;

	protected $shouldSaveValue;
	
	// Function
	protected $focus;
	protected $blur;
	protected $change;
	protected $changed;
	protected $click;

	/**
	 * Constructeur
	 * @param unknown_type $id
	 * @param unknown_type $name
	 * @param unknown_type $type
	 */
	public function FormItem($name, $type) {
		$this->name = $name;
		$this->type = $type;
		$this->validators = array();
	}
	
	/**
	 * Defini Javascript sur click
	 * @param unknown_type $expression
	 */
	public function setJSClick($expression) {
		$this->click = new FunctionType(array('form','item'), $expression);
	}
	
	/**
	 * Defini Javascript sur focus
	 * @param unknown_type $expression
	 */
	public function setJSFocus($expression) {
		$this->focus = new FunctionType(array('form','item'), $expression);
	}
	
	/**
	 * Defini Javascript sur blur
	 * @param unknown_type $expression
	 */
	public function setJSBlur($expression) {
		$this->blur = new FunctionType(array('form','item'), $expression);
	}
	
	
	/**
	 * Defini Javascript sur change
	 * @param unknown_type $expression
	 */
	public function setJSChange($expression) {
		$this->change = new FunctionType(array('form','item','value','oldvalue'), $expression);
	}
	
	
	/**
	 * Defini Javascript sur changed
	 * @param unknown_type $expression
	 */
	public function setJSChanged($expression) {
		$this->changed = new FunctionType(array('form','item','value'), $expression);
	}
	
	/**
	 * Ajoute un validateur
	 * @param ValidatorType $val
	 */
	public function addValidator(ValidatorType $val) {
		$this->validators[] = $val;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
}
?>